/* JUGJobs -- A Jobs Posting Application for Java Users Groups and Other Groups
 * $Id: TextAndHtmlUtilities.java,v 1.2 2006/04/30 23:03:21 biglee Exp $
 * 
 * ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is the JUGJobs project.
 *
 * The Initial Developers of the Original Code are the members of the Triangle
 * Java User's Group in the RTP area of North Carolina.
 * Portions created by the Initial Developer are Copyright (C) 2005
 * the Initial Developers. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** 
 */
package org.jugjobs.util;

import java.util.HashMap;

public class TextAndHtmlUtilities {
	
	public final static int SUMMARY_SIZE = 500;

	private final static String[] balancingTags = 
	{ "I","B","DIV","SPAN","TABLE","TR","TH","TD","UL","FONT","A","BLOCKQUOTE" };
	private static HashMap balancingTagMap = null;
	public static HashMap getBalancingTagMap() {
		if(balancingTagMap==null) {
			balancingTagMap = new HashMap(balancingTags.length);
			for(int i=0;i<balancingTags.length;i++) {
				balancingTagMap.put(balancingTags[i],new Integer(i));
			}
		}
		return balancingTagMap;
	}
	
	private final static String[] nonBalancingTags = 
	{ "P","HR","BR","IMG","LI" };
	private static HashMap nonBalancingTagMap = null;
	public static HashMap getNonBalancingTagMap() {
		if(nonBalancingTagMap==null) {
			nonBalancingTagMap = new HashMap(nonBalancingTags.length);
			for(int i=0;i<nonBalancingTags.length;i++) {
				nonBalancingTagMap.put(nonBalancingTags[i],new Integer(i));
			}
		}
		return nonBalancingTagMap;
	}
	
	private static HashMap legalChildren = null;
	public static HashMap getLegalChildren() {
		if(legalChildren==null) {
			legalChildren = new HashMap();
			HashMap children = new HashMap(1);
			children.put("TR","TR");
			legalChildren.put("TABLE",children);
			children=new HashMap(2);
			children.put("TD","TD");
			children.put("TH","TH");
			legalChildren.put("TR",children);
			children = new HashMap(1);
			children.put("LI","LI");
			legalChildren.put("UL",children);
		}
		return legalChildren;
	}

	private final static String[] summaryTags = 
	{ "I","B","DIV","SPAN","FONT","A","P","HR","BR" };
	private static HashMap summaryTagMap = null;
	public static HashMap getSummaryTagMap() {
		if(summaryTagMap==null) {
			summaryTagMap = new HashMap(summaryTags.length);
			for(int i=0;i<summaryTags.length;i++) {
				summaryTagMap.put(summaryTags[i],new Integer(i));
			}
		}
		return summaryTagMap;
	}

}
